package com.qdy.web;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * Created by qudingyi on 2017/4/14.
 */

@Controller
public class MainController {


    @RequestMapping("/venue/manage")
    public ModelAndView manage(){
        return new ModelAndView("venue/home");
    }
    @RequestMapping("/venue/register")
    public ModelAndView register(){
        return new ModelAndView("venue/register");
    }
    @RequestMapping("/venue/login")
    public ModelAndView venueLogin(HttpServletRequest request, String userName, String password){
        ModelAndView view=new ModelAndView("redirect:venue/manage");
        return view;
       /* if(request.getSession().getAttribute("venue")!=null){
            dto.setViewName("redirect:venue/manage");
            return  dto;
        }
       VenueSearch search=new VenueSearch();
        search.setUserName(userName);
        try {
            List<Venue> venues=venueService.findByParams(search);
            if(venues!=null &&venues.size()>0 ){
                if(new MD5().getMD5ofStr(password).equals(venues.get(0).getUserPassword())){
                    dto.setViewName("redirect:venue/manage");
                    return  dto;
                }else{
                    dto.setViewName("venue/login");
                    dto.addObject("error","密码错误");
                    return dto;
                }
            }else{
                dto.setViewName("venue/login");
                dto.addObject("error","用户不存在");
                return dto;
            }
        }catch (Exception e){
                dto.setViewName("venue/login");
                dto.addObject("error","登录失败");
                return dto;
        }*/
  }
}
